Repository navigation
Enhance indentation of blocks - #151
Conversation
|
Hey, thank you for the contribution! It has docs, maintains backward compability, and the change is very focused and self-contained. Great stuff! Could you please add some tests to ensure this behaviour is not lost in any potential refactoring down the road? |
1068951 to
aee46da
Compare
|
I've also added E.g., With local foo = setmetatable( {
a = 4,
b = 5,
}, {
__index = some_func,
} )With local foo = setmetatable( {
a = 4,
b = 5,
}, {
__index = some_func,
} ) |
|
Hey, awesome stuff with the tests, but I'm not sure if we need the |
|
The E.g., Default settings: call_some_fn( something, {
val = 5,
val = 7,
}, {
val = 6,
} )With call_some_fn( something, {
val = 5,
val = 7,
}, {
val = 6,
} )With call_some_fn( something, {
val = 5,
val = 7,
}, {
val = 6,
} )With both call_some_fn( something, {
val = 5,
val = 7,
}, {
val = 6,
} ) |
|
Would you like me to combine |
Hmm... I think I missed one case here. My original idea stemmed from the fact that there could be different preferences w.r.t. where should the table content go:
But I couldn't find a reason for the closing brace to be anywhere else but at content indentation minus 1 indentation offset. This was about the case when there is no potential alignment inside the table, i.e. when the inside table elements start on the subsequent line, But then your comment made me realize that there are still cases when the first element in the nested table is on the same row as the opening brace and it creates an alignment dilemma, so to speak, even without the outer function call: -- this looks fine
foo = {1,
2,
3}
-- but the following two look strange
foo = {1,
2,
3
}
foo = {1,
2,
3
}
-- although less strange than "minus one level of indentation"
foo = {1,
2,
3
}So I guess it would make sense to introduce a variable for people to "pick their poison" in cases when table elements are aligned, but the close brace is on a separate line. |
|
So are you saying to leave it as it is, so the user has the choice? 🤔 |
|
Sorry for the delay here. I'm going to merge it. Thank you for your work and for your patience! |
|
Hey! Looks like foobar(123,
456)In this example there are no nested blocks, but since alignment is disabled, 456 is indented instead. |
Added
lua-indent-nested-block-content-alignvar, which disables the aligning of content of nested blocks to the opening brace and indents normally. It defaults tot, which is the previous behaviour.E.g. 1:
With
lua-indent-nested-block-content-alignsett(default), then:Wth
lua-indent-nested-block-content-alignsetnil, then:E.g. 2:
With
lua-indent-nested-block-content-alignsett(default), then:Wth
lua-indent-nested-block-content-alignsetnil, then: